package com.myrecycleview631wrydata.activity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import cst.a613ld.recycleview613ld.R;

public class RegtisterActivity extends AppCompatActivity implements View.OnClickListener{
    private TextView text_account;
    private TextView text_pass_one;
    private TextView text_pass_two;
    private EditText ed_account;
    private EditText ed_pass_one;
    private EditText ed_pass_two;
    private Button bu_regtister;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.regtisteractivity);
        init();
    }
    private void init()
    {
        text_account=(TextView)findViewById(R.id.textView_account);
        text_pass_one=(TextView)findViewById(R.id.textView_pass_one);
        text_pass_two=(TextView)findViewById(R.id.textView_pass_two);
        ed_account=(EditText)findViewById(R.id.editText_account);
        ed_pass_one=(EditText)findViewById(R.id.editText_pass_one);
        ed_pass_two=(EditText)findViewById(R.id.editText_pass_two);
        bu_regtister=(Button)findViewById(R.id.button_regtister);
        bu_regtister.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.button_regtister:
                if(ed_account.getText().toString().charAt(0)>='a' && ed_account.getText().toString().charAt(0)<='z'
                        && ed_account.getText().toString().length()>=6 && ed_account.getText().toString().length()<=13
                        && ed_pass_one.getText().toString().length()>=6 && ed_pass_one.getText().toString().length()<=15
                        && ed_pass_one.getText().toString().equals(ed_pass_two.getText().toString())
                        )
                {
                    new AlertDialog.Builder(RegtisterActivity.this).setTitle("温馨提示")
                            .setMessage("注册成功。").
                            setPositiveButton("确定",new DialogInterface.OnClickListener()
                                    {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            finish();
                                        }
                                    }
                            )
                            .show();

                }
                break;
            default:break;
        }
    }
}
